/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2023-05-13
 * Time: 13:09
 */
public class Test {

    /**
     *
     * @param pos1 起始位置
     * @param pos2 中转位置
     * @param pos3 目标位置
     * @param n
     *
     */
    public static void hanio(int n, char pos1, char pos2, char pos3){
        if(n == 1){
            move(pos1, pos3);
            return;
        }
        hanio(n-1, pos1, pos3, pos2);
        move(pos1, pos3);
        hanio(n-1, pos2, pos1, pos3);
    }

    /**
     *
     * @param pos1 起始位置
     * @param pos2 目标位置
     */
    public static void move(char pos1, char pos2){
        System.out.print(pos1+" -> "+pos2+" ");
    }

    public static void main(String[] args) {
        hanio(1, 'A', 'B', 'C');
        System.out.println();
        hanio(2, 'A', 'B', 'C');
        System.out.println();
        hanio(3, 'A', 'B', 'C');
    }

    public static void print(int n) {
        if(n<10){
            System.out.println(n);
            return;
        }
        print(n/10);
        System.out.println(n%10);
    }

    public static int sum(int n){
        if(n < 10){
            return n;
        }
        int tmp = n%10 + sum(n/10);
        return tmp;
    }

    public static int func2(int n){
        if(n == 1){
            return 1;
        }
        return n + func2(n-1);
    }

    public static int fib2(int n){
        if(n == 1 || n == 2){
            return 1;
        }
        return fib2(n-1) + fib2(n-2);
    }

    public static void main3(String[] args) {
        System.out.println(fib2(10));
    }

    public static int fac(int n) {
        if(n == 1){
            return 1;
        }
        int tmp = n * fac(n-1);
        return tmp;
    }

    public static void main2(String[] args) {
        System.out.println(fac(5));
    }

    public static void function(int a) {
        if(a == 1){
            System.out.println(a);
            return;
        }
        function(a-1);
        System.out.println(a);
    }

    public static void main1(String[] args) {
        function(3);
    }
}
